<?php

namespace App\Models;

use App\Events\AdminCreating;
use App\Events\AdminUpdating;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class User extends Model
{
    protected $table = 'user';
    protected $hidden = ['password'];
//    protected $fillable = ['username','password','nickname','mobile','avatar','regdateline','nationality','address','source','parentid','isneedsaveinfo','status','open_id'];
    public $timestamps = false;
    protected $primaryKey = 'uid';
    protected $guarded = [];


    // 状态
    const STATUS_SHOW = '1';
    const STATUS_DELETE = '2';
    public static $STATUS = array(
        self::STATUS_SHOW => array('name' => '上线'),
        self::STATUS_DELETE => array('name' => '下线'),
    );

    public static function getList($where)
    {

        $data = User::orderBy('uid','desc');


        if(!empty($where['mobile']))
        {
            $data->where('mobile','like','%'.$where['mobile'].'%');

        }

        if(!empty($where['name']))
        {
            $data->where('name','like','%'.$where['name'].'%');
        }

        return $data->paginate(20);
    }
    
}
